package cha.app.pong;

import android.app.Activity;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.util.Log;

public class GameContainer extends Activity {
  private static final String TAG = "GameContainer";
  private Pong game;
  public void onCreate(Bundle savedState){
    super.onCreate( savedState );
    DisplayMetrics screen = new DisplayMetrics();
    getWindow().getWindowManager().getDefaultDisplay().getMetrics(screen);
    
    Bundle init_args = getIntent().getExtras();
    
    game = null;
    switch(init_args.getInt( "difficulty" )){
      case Utilities.EASY_MODE:
        game = new Pong(this.getApplicationContext(), Utilities.EASY_MODE, screen);
        break;
      case Utilities.NORM_MODE:
        game = new Pong(this.getApplicationContext(), Utilities.NORM_MODE, screen);
        break;
      case Utilities.HARD_MODE:
        game = new Pong(this.getApplicationContext(), Utilities.HARD_MODE, screen);
        break;
      default:
        Log.d(TAG, "Unknown Difficulty Level");
      break;
    }
    
    if(!game.equals( null ))
      setContentView(game);
    else
      Log.d(TAG, "Unknown Difficulty Level");
  }
  
  public void onDestroy(){
    super.onDestroy();
    if(!game.equals( null ))
      game.destroy();
  }
}
